/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package cn.knet.sp.ncrm.modules.call.log.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.knet.sp.ncrm.common.config.Global;
import cn.knet.sp.ncrm.common.persistence.Page;
import cn.knet.sp.ncrm.common.utils.StringUtils;
import cn.knet.sp.ncrm.common.web.BaseController;
import cn.knet.sp.ncrm.modules.call.log.entity.CallReportStatLog;
import cn.knet.sp.ncrm.modules.call.log.service.CallReportStatLogService;

/**
 * 单表生成Controller
 *
 * @author zhangbin
 * @version 2015-08-03
 */
@Controller
@RequestMapping(value = "${adminPath}/call/log/callReportStatLog")
public class CallReportStatLogController extends BaseController {

	@Autowired
	private CallReportStatLogService callReportStatLogService;

	@ModelAttribute
	public CallReportStatLog get(@RequestParam(required = false) String id) {
		CallReportStatLog entity = null;
		if (StringUtils.isNotBlank(id)) {
			entity = callReportStatLogService.get(id);
		}
		if (entity == null) {
			entity = new CallReportStatLog();
		}
		return entity;
	}

	@RequestMapping(value = {"list", ""})
	public String list() {
		return "modules/call/log/callReportStatLogAjaxList";
	}

	@RequestMapping(value = "listAjaxData")
	@ResponseBody
	public Page listAjaxData(CallReportStatLog callReportStatLog, HttpServletRequest request,
							 HttpServletResponse response, Model model) {
		Page<CallReportStatLog>
				page =
				callReportStatLogService.findPage(new Page<CallReportStatLog>(request, response), callReportStatLog);
		return page;
	}

}